<?php
class Comment_BlockController extends Clu_Controller_Action_Mini
{
	public $m, $mPlace, $mArticle;
	
	public function init()
	{
		//require_once (APP_PATH.'/modules/place/Model/Place.php');
		//require_once (APP_PATH.'/modules/article/Model/Article.php');
		//require_once (APP_PATH.'/modules/comment/Model/Comment.php');
		//require_once (APP_PATH.'/modules/comment/Form/Comment.php');
		//require_once (APP_PATH.'/modules/comment/Form/CommentSearch.php');
		
		$this->mPlace = new place_Model_Place();
		$this->mArticle = new article_Model_Service();
		$this->m = new comment_Model_Service();
		parent::init();
	}
	
	public function moduleCommentAction()
	{
		$id = $this->miniRequest['id'];
		$regionId = $this->miniRequest['regionId'];
		$boxWeight = $this->miniRequest['boxWeight'];
		$comments_per_page = $this->miniRequest['comments_per_page'];
		$page_number = $this->miniRequest['page_number'];
		$content_type = $this->miniRequest['content_type'];
		$formSearch = new comment_comment_Form_CommentSearch();
        $formSearch->cluBuild(array('control' => 'service'));
		$this->view->formSearch = $formSearch;
		
		//new Comment Box
		$form2 = new comment_Form_Comment();
		$form2->cluBuild(array('action' => 'new','control' => 'ajax'));
		$this->view->form2 = $form2;
		//comment list + pagination
       	$select = $this->m->search($id);
		$paginator = new Zend_Paginator(new Zend_Paginator_Adapter_DbSelect($select));
		$paginator->setItemCountPerPage($comments_per_page);
		$paginator->setCurrentPageNumber($page_number);
		Zend_Paginator::setDefaultScrollingStyle('Jumping');
		$this->view->paginator = $paginator;
		$this->view->cList = $paginator->getCurrentItems();
//		die_a($this->view->cList);
		//TODO: Set page number to HTML
		//views/scripts/comm
//		$this->view->commentList = $this->view->render('/commonTheme/nolang/index/commentList.phtml');
//		die($id);
		//additional info: parent type, parent id
		$this->view->content_type = $content_type;
		$this->view->content_id = $id;
		$this->view->id = $id;
		$this->renderToHolder('block/module_comment.phtml', false, null, $regionId,  $boxWeight);
		
	}
}	
?>
